package yy.soft.common;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;

@Data
public class ResultsInfo<T> extends ResultInfoBase{
    @JsonProperty("Result")
    private List<T> Result;

    @JsonProperty("total")
    private long total;

    public ResultsInfo<T> ok (List<T> result){
        this.setSuccess(true);
        this.setResult(result);
        return this;
    }

    public ResultsInfo<T> ok (List<T> result,String msg){
        this.setSuccess(true);
        this.setResult(result);
        this.setMsg(msg);
        return this;
    }

    public ResultsInfo<T> ok (List<T> result,long total){
        this.setSuccess(true);
        this.setResult(result);
        this.setTotal(total);
        return this;
    }

    public ResultsInfo<T> ok (List<T> result,long total,String msg){
        this.setSuccess(true);
        this.setResult(result);
        this.setMsg(msg);
        this.setTotal(total);
        return this;
    }

    public ResultsInfo<T> error(String msg){
        this.setSuccess(false);
        this.setMsg(msg);
        return this;
    }

    public ResultsInfo<T> error(String msg,String info){
        this.setSuccess(false);
        this.setMsg(msg);
        this.setInfo(info);
        return this;
    }
}